(function () {
  //选取元素
  let jptjList = document.querySelector("#jptjList");
  let jptjLeftBtn = document.querySelector("#jptjLeftBtn");
  let jptjRightBtn = document.querySelector("#jptjRightBtn");
  let cnt = 0;
  //函数节流
  let lock = true;

  //右按钮

  jptjRightBtn.onclick = function () {
    if (!lock) return;
    lock = false;
    if (cnt == 2) {
      setTimeout(() => {
        lock = true;
      }, 500);
      return;
    }
    cnt++;
    jptjList.style.transform = `translateX(${-(340 + 19) * cnt}px)`;
    setTimeout(() => {
      lock = true;
    }, 500);
  };

  //左按钮
  jptjLeftBtn.onclick = function () {
    if (!lock) return;
    lock = false;
    if (cnt == 0) {
      setTimeout(() => {
        lock = true;
      }, 500);
      return;
    }
    cnt--;
    jptjList.style.transform = `translateX(${-(340 + 19) * cnt}px)`;
    setTimeout(() => {
      lock = true;
    }, 500);
  };
})();
